package org.jeeasy.system.api.config;

import org.jeeasy.common.api.FeignRequestInterceptor;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FeignConfiguration extends FeignRequestInterceptor {
    //@Override
    //public void apply(RequestTemplate template) {
    //    //开启线程共享
    //    RequestContextHolder.setRequestAttributes(RequestContextHolder.getRequestAttributes(), true);
    //    ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
    //    HttpServletRequest request = attributes.getRequest();
    //    // 对消息头进行配置
    //    Enumeration<String> headerNames = request.getHeaderNames();
    //    if (headerNames != null) {
    //        while (headerNames.hasMoreElements()) {
    //            String name = headerNames.nextElement();
    //            String values = request.getHeader(name);
    //            template.header(name, values);
    //        }
    //    }
    //    // 对请求体进行配置
    //   /* Enumeration<String> bodyNames = request.getParameterNames();
    //    StringBuffer body = new StringBuffer();
    //    if (bodyNames != null) {
    //        while (bodyNames.hasMoreElements()) {
    //            String name = bodyNames.nextElement();
    //            String values = request.getParameter(name);
    //            body.append(name).append("=").append(values).append("&");
    //        }
    //    }
    //    if (body.length() != 0) {
    //        body.deleteCharAt(body.length() - 1);
    //        template.body(body.toString());
    //    }*/
    //}
}
